package com.jgy.策略模式;

import com.jgy.策略And工厂模式.FactoryEnum;

/**
 * @author 姜光远
 * @date 2022/12/14 16:20
 */
public class Test {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        CountPrice aCountPrice = new ACountPrice();
        CountPrice bCountPrice = new BCountPrice();
        CountPrice countPrice = new CCountPrice();
        CountPriceContext acountPriceContext = new CountPriceContext(aCountPrice);
        CountPriceContext bcountPriceContext = new CountPriceContext(bCountPrice);
        CountPriceContext ccountPriceContext = new CountPriceContext(countPrice);

        System.out.println(acountPriceContext.Count(21.75,20));
        System.out.println(bcountPriceContext.Count(31.21, 70));
        System.out.println(ccountPriceContext.Count(100d, 30));

        System.out.println((CountPrice) Class.forName(FactoryEnum.getClassNameByCode("1")).newInstance());

    }
}
